using AutoMapper;
using B.S.XZYData.Api.Read.Application.Command.Route;
using B.S.XZYData.Api.Read.Dto.Route;
using B.S.XZYData.Domain.LJC;
using B.S.XZYData.Domain.ZSHH;

namespace B.S.XZYData.Api.Read.Profiles
{
    /// <summary>
    /// 工艺路线AutoMapper映射配置
    /// </summary>
    public class RouteProfile : Profile
    {
        public RouteProfile()
        {
            // RouteModel -> RouteDto
            CreateMap<RouteModel, RouteDto>()
                .ForMember(dest => dest.EnableApproval, opt => opt.MapFrom(src => src.Approved == 1));

            // RouteModel -> RouteDetailDto
            CreateMap<RouteModel, RouteDetailDto>()
                .ForMember(dest => dest.EnableApproval, opt => opt.MapFrom(src => src.Approved == 1));

            // Process -> RouteStepDto (配置字段映射)
            CreateMap<B.S.XZYData.Domain.ZSHH.Process, RouteStepDto>()
                .ForMember(dest => dest.RouteId, opt => opt.MapFrom(src => src.RoutdId))
                .ForMember(dest => dest.ProcessCode, opt => opt.MapFrom(src => src.ProcessNumber))
                .ForMember(dest => dest.Ratio, opt => opt.MapFrom(src => src.ReportingRatio))
                .ForMember(dest => dest.ReportingPermissions, opt => opt.MapFrom(src => src.ReportingPermissions))
                .ForMember(dest => dest.DefectiveItemList, opt => opt.MapFrom(src => src.DefectiveItemList))
                .ForMember(dest => dest.TestField1, opt => opt.MapFrom(src => src.TestField1))
                .ForMember(dest => dest.TestField2, opt => opt.MapFrom(src => src.TestField2))
                .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.CreatorDate))
                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.UpdatorDate));
        }
    }
} 